{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6cd1780d-8559-4978-86b4-1a248b13d4ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 在jupyterlab中使用pyecharts的环境设置\n",
    "from pyecharts.globals import CurrentConfig, NotebookType\n",
    "CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cf239071-e8ba-46ca-ac4c-be1f81d46e4d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入包\n",
    "\n",
    "# Faker是pyecharts提供的一个测试数据生成模块\n",
    "from pyecharts.faker import Faker\n",
    "# Bar是条形图和Scatter是散点图\n",
    "from pyecharts.charts import Bar, Scatter\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.commons.utils import JsCode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c74a4b0c-371d-4010-b385-8b6f3688e5cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on _Faker in module pyecharts.faker object:\n",
      "\n",
      "class _Faker(builtins.object)\n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  choose(self) -> list\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  img_path(path: str, prefix: str = 'images') -> str\n",
      " |  \n",
      " |  rand_color() -> str\n",
      " |  \n",
      " |  values(start: int = 20, end: int = 150) -> list\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors defined here:\n",
      " |  \n",
      " |  __dict__\n",
      " |      dictionary for instance variables (if defined)\n",
      " |  \n",
      " |  __weakref__\n",
      " |      list of weak references to the object (if defined)\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data and other attributes defined here:\n",
      " |  \n",
      " |  animal = ['河马', '蟒蛇', '老虎', '大象', '兔子', '熊猫', '狮子']\n",
      " |  \n",
      " |  cars = ['宝马', '法拉利', '奔驰', '奥迪', '大众', '丰田', '特斯拉']\n",
      " |  \n",
      " |  clock = ['12a', '1a', '2a', '3a', '4a', '5a', '6a', '7a', '8a', '9a', ...\n",
      " |  \n",
      " |  clothes = ['衬衫', '毛衣', '领带', '裤子', '风衣', '高跟鞋', '袜子']\n",
      " |  \n",
      " |  country = ['China', 'Canada', 'Brazil', 'Russia', 'United States', 'Af...\n",
      " |  \n",
      " |  days_attrs = ['0天', '1天', '2天', '3天', '4天', '5天', '6天', '7天', '8天', '9...\n",
      " |  \n",
      " |  days_values = [22, 1, 6, 4, 4, 2, 4, 10, 16, 15, 23, 10, 25, 1, 8, 19,...\n",
      " |  \n",
      " |  dogs = ['哈士奇', '萨摩耶', '泰迪', '金毛', '牧羊犬', '吉娃娃', '柯基']\n",
      " |  \n",
      " |  drinks = ['可乐', '雪碧', '橙汁', '绿茶', '奶茶', '百威', '青岛']\n",
      " |  \n",
      " |  fruits = ['草莓', '芒果', '葡萄', '雪梨', '西瓜', '柠檬', '车厘子']\n",
      " |  \n",
      " |  guangdong_city = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市', '广州市', '惠州市']\n",
      " |  \n",
      " |  months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',...\n",
      " |  \n",
      " |  phones = ['小米', '三星', '华为', '苹果', '魅族', 'VIVO', 'OPPO']\n",
      " |  \n",
      " |  provinces = ['广东省', '北京市', '上海市', '江西省', '湖南省', '浙江省', '江苏省']\n",
      " |  \n",
      " |  visual_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8',...\n",
      " |  \n",
      " |  week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']\n",
      " |  \n",
      " |  week_en = ['Saturday', 'Friday', 'Thursday', 'Wednesday', 'Tuesday', '...\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(Faker)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "e4338235-0ed8-489f-86e0-8b6cfd38576c",
   "metadata": {},
   "source": [
    "## 设置初始化配置项\n",
    "\n",
    "通过绘图对象构造函数的`init_opts`参数接收的的`InitOpts`对象\n",
    "\n",
    "### InitOpts - 初始化配置项\n",
    "\n",
    "配置图像的宽度、高度、主题风格、背景色等信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a391742d-bef9-4eec-91cd-6b38b6e846b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"7f8e72171297448fbd44215bdf8b0c44\" class=\"chart-container\" style=\"width:400px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_7f8e72171297448fbd44215bdf8b0c44 = echarts.init(\n",
       "            document.getElementById('7f8e72171297448fbd44215bdf8b0c44'), 'white', {renderer: 'canvas'});\n",
       "        var option_7f8e72171297448fbd44215bdf8b0c44 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4ea7\\u54c1\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                26,\n",
       "                25,\n",
       "                79,\n",
       "                101,\n",
       "                148,\n",
       "                48,\n",
       "                29\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4ea7\\u54c1\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c73\",\n",
       "                \"\\u4e09\\u661f\",\n",
       "                \"\\u534e\\u4e3a\",\n",
       "                \"\\u82f9\\u679c\",\n",
       "                \"\\u9b45\\u65cf\",\n",
       "                \"VIVO\",\n",
       "                \"OPPO\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_7f8e72171297448fbd44215bdf8b0c44.setOption(option_7f8e72171297448fbd44215bdf8b0c44);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111036c50>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = (\n",
    "    # 初始化设置图片宽400px，高300px\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width=\"400px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    .add_xaxis(Faker.choose()) # 使用Faker随机生成x轴数据\n",
    "    .add_yaxis(\"产品\", Faker.values()) #使用Faker随机生成y轴数据\n",
    ")\n",
    "# 绘图\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90b5ad2f-99c4-497b-ab9c-7d558bdfcbd7",
   "metadata": {},
   "source": [
    "#### AnimationOpts - 动画配置项\n",
    "\n",
    "配置图像是否开启动画（默认是True），做大量数据分析的时候可以考虑在初始化项中将其设为False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "92675d6e-9780-4e86-a350-5d1e2860f21b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"3eb4a03de3ba49da85b1583cc10cbc6d\" class=\"chart-container\" style=\"width:400px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_3eb4a03de3ba49da85b1583cc10cbc6d = echarts.init(\n",
       "            document.getElementById('3eb4a03de3ba49da85b1583cc10cbc6d'), 'white', {renderer: 'canvas'});\n",
       "        var option_3eb4a03de3ba49da85b1583cc10cbc6d = {\n",
       "    \"animation\": false,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4ea7\\u54c1\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                36,\n",
       "                54,\n",
       "                86,\n",
       "                106,\n",
       "                51,\n",
       "                21,\n",
       "                132\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4ea7\\u54c1\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u54c8\\u58eb\\u5947\",\n",
       "                \"\\u8428\\u6469\\u8036\",\n",
       "                \"\\u6cf0\\u8fea\",\n",
       "                \"\\u91d1\\u6bdb\",\n",
       "                \"\\u7267\\u7f8a\\u72ac\",\n",
       "                \"\\u5409\\u5a03\\u5a03\",\n",
       "                \"\\u67ef\\u57fa\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_3eb4a03de3ba49da85b1583cc10cbc6d.setOption(option_3eb4a03de3ba49da85b1583cc10cbc6d);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1110e94d0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = (\n",
    "    # 初始化设置图片宽400px，高300px\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width=\"400px\",\n",
    "        height=\"300px\",\n",
    "        animation_opts = opts.AnimationOpts(animation=False)\n",
    "    ))\n",
    "    .add_xaxis(Faker.choose()) # 使用Faker随机生成x轴数据\n",
    "    .add_yaxis(\"产品\", Faker.values()) #使用Faker随机生成y轴数据\n",
    ")\n",
    "# 绘图\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8396b0ed-9f91-4f04-869a-860fe173116f",
   "metadata": {},
   "source": [
    "## 设置初始化配置项\n",
    "\n",
    "通过绘图对象的`set_global_opts`函数接收配置项对象\n",
    "\n",
    "### TitleOpts - 标题配置项\n",
    "\n",
    "配置图像的标题和子标题**在set_global_opts中配置**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "91ff62fa-7bcf-4db0-b587-55e08241fbfe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"9fbebd9f12ec4a0cb29efe0118acac04\" class=\"chart-container\" style=\"width:400px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_9fbebd9f12ec4a0cb29efe0118acac04 = echarts.init(\n",
       "            document.getElementById('9fbebd9f12ec4a0cb29efe0118acac04'), 'white', {renderer: 'canvas'});\n",
       "        var option_9fbebd9f12ec4a0cb29efe0118acac04 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4ea7\\u54c1\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                112,\n",
       "                68,\n",
       "                20,\n",
       "                100,\n",
       "                20,\n",
       "                149,\n",
       "                20\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4ea7\\u54c1\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u8349\\u8393\",\n",
       "                \"\\u8292\\u679c\",\n",
       "                \"\\u8461\\u8404\",\n",
       "                \"\\u96ea\\u68a8\",\n",
       "                \"\\u897f\\u74dc\",\n",
       "                \"\\u67e0\\u6aac\",\n",
       "                \"\\u8f66\\u5398\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u4ea7\\u54c1\\u9500\\u91cf\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtext\": \"\\uff08\\u4e2a\\uff09\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"right\": \"25px\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false,\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_9fbebd9f12ec4a0cb29efe0118acac04.setOption(option_9fbebd9f12ec4a0cb29efe0118acac04);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111480b50>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = (\n",
    "    # 初始化设置图片宽400px，高300px\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width=\"400px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    .add_xaxis(Faker.choose()) # 使用Faker随机生成x轴数据\n",
    "    .add_yaxis(\"产品\", Faker.values()) #使用Faker随机生成y轴数据\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts( # 设置标题相关信息\n",
    "            title=\"产品销量\", # 设置标题名\n",
    "            subtitle=\"（个）\", # 设置子标题\n",
    "            # 设置标题位置距离右边25px，也可以设置其他位置，例如 pos_top\n",
    "            pos_right=\"25px\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(font_size=12) # 设置标题字体风格\n",
    "        )\n",
    "    )\n",
    ")\n",
    "# 绘图\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8e3bcec-a825-46f4-9a28-b7bb1269a506",
   "metadata": {},
   "source": [
    "### LegendOpts - 图例配置项\n",
    "\n",
    "配置图像的图例**在set_global_opts中配置**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3f4103bd-9895-42f5-9b7d-242e6de63eb5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"24c7240e94674d18a451894b11a43581\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_24c7240e94674d18a451894b11a43581 = echarts.init(\n",
       "            document.getElementById('24c7240e94674d18a451894b11a43581'), 'white', {renderer: 'canvas'});\n",
       "        var option_24c7240e94674d18a451894b11a43581 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb61\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                91,\n",
       "                73,\n",
       "                93,\n",
       "                108,\n",
       "                82,\n",
       "                79,\n",
       "                64\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": 0,\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb62\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                131,\n",
       "                73,\n",
       "                142,\n",
       "                74,\n",
       "                87,\n",
       "                69,\n",
       "                25\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": 0,\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb61\",\n",
       "                \"\\u5546\\u5bb62\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"selectedMode\": \"single\",\n",
       "            \"show\": true,\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5468\\u4e00\",\n",
       "                \"\\u5468\\u4e8c\",\n",
       "                \"\\u5468\\u4e09\",\n",
       "                \"\\u5468\\u56db\",\n",
       "                \"\\u5468\\u4e94\",\n",
       "                \"\\u5468\\u516d\",\n",
       "                \"\\u5468\\u65e5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u4ea7\\u54c1\\u9500\\u91cf\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtext\": \"\\uff08\\u4e2a\\uff09\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"right\": \"25px\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false,\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_24c7240e94674d18a451894b11a43581.setOption(option_24c7240e94674d18a451894b11a43581);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x11105aad0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = (\n",
    "    # 初始化设置Bar图片宽600px，高300px\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.choose())\n",
    "    #使用Faker随机生成y轴数据\n",
    "        # gap=0，设置条行间的间隔为0\n",
    "    .add_yaxis(\"商家1\", Faker.values(), gap=0)\n",
    "    #添加一组新的y轴取值，使用Faker随机生成y轴数据\n",
    "        # gap=0，设置条行间的间隔为0\n",
    "    .add_yaxis(\"商家2\", Faker.values(), gap=0)\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts( # 设置标题相关信息\n",
    "            title=\"产品销量\", # 设置标题名\n",
    "            subtitle=\"（个）\", # 设置子标题\n",
    "            pos_right=\"25px\", # 设置标题位置距离右边25px\n",
    "            title_textstyle_opts=opts.TextStyleOpts(font_size=12) # 设置标题字体风格\n",
    "        ),\n",
    "        legend_opts=opts.LegendOpts(\n",
    "            selected_mode=\"single\", # 设置每次只能选择显式一种图例对应的数据（默认是multiple）\n",
    "            orient=\"vertical\" # 设置图例垂直排列显示（默认是horizontal）\n",
    "        )\n",
    "    )\n",
    ")\n",
    "# 绘图\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a867a3a-7bb5-445c-8443-8283adc3eea0",
   "metadata": {},
   "source": [
    "### VisualMapOpts - 视觉映射配置项\n",
    "\n",
    "配置图像的视觉映射效果**在set_global_opts中配置**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b0cff589-48a0-4f89-bb8f-fd755c1d3408",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[(71, 32), (89, 109), (62, 110), (150, 70), (73, 124), (47, 135), (147, 106)]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"2481a6fdbd5e4a519996fe195ec3cd4f\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_2481a6fdbd5e4a519996fe195ec3cd4f = echarts.init(\n",
       "            document.getElementById('2481a6fdbd5e4a519996fe195ec3cd4f'), 'white', {renderer: 'canvas'});\n",
       "        var option_2481a6fdbd5e4a519996fe195ec3cd4f = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"\\u5546\\u5bb6\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u886c\\u886b\",\n",
       "                    71,\n",
       "                    32\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u6bdb\\u8863\",\n",
       "                    89,\n",
       "                    109\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9886\\u5e26\",\n",
       "                    62,\n",
       "                    110\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u88e4\\u5b50\",\n",
       "                    150,\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u98ce\\u8863\",\n",
       "                    73,\n",
       "                    124\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                    47,\n",
       "                    135\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u889c\\u5b50\",\n",
       "                    147,\n",
       "                    106\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u886c\\u886b\",\n",
       "                \"\\u6bdb\\u8863\",\n",
       "                \"\\u9886\\u5e26\",\n",
       "                \"\\u88e4\\u5b50\",\n",
       "                \"\\u98ce\\u8863\",\n",
       "                \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                \"\\u889c\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_2481a6fdbd5e4a519996fe195ec3cd4f.setOption(option_2481a6fdbd5e4a519996fe195ec3cd4f);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111120c50>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yValues = [(a, b) for a,b in zip(Faker.values(), Faker.values())]\n",
    "print(yValues)\n",
    "scatter = (\n",
    "    # 初始化设置Scatter图片宽600px，高300px\n",
    "    Scatter(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.clothes)\n",
    "    #使用Faker随机生成y轴数据\n",
    "    .add_yaxis(\"商家\", yValues)\n",
    ")\n",
    "# 绘图，默认没有设置视觉映射时只展示y轴上第一个维度的值\n",
    "scatter.render_notebook() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3c29b0c5-2a63-4a24-ae81-39e47fb092fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"39309917bf49442dbdcc1e2c5c6eb619\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_39309917bf49442dbdcc1e2c5c6eb619 = echarts.init(\n",
       "            document.getElementById('39309917bf49442dbdcc1e2c5c6eb619'), 'white', {renderer: 'canvas'});\n",
       "        var option_39309917bf49442dbdcc1e2c5c6eb619 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"\\u5546\\u5bb6\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u886c\\u886b\",\n",
       "                    71,\n",
       "                    32\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u6bdb\\u8863\",\n",
       "                    89,\n",
       "                    109\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9886\\u5e26\",\n",
       "                    62,\n",
       "                    110\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u88e4\\u5b50\",\n",
       "                    150,\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u98ce\\u8863\",\n",
       "                    73,\n",
       "                    124\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                    47,\n",
       "                    135\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u889c\\u5b50\",\n",
       "                    147,\n",
       "                    106\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u886c\\u886b\",\n",
       "                \"\\u6bdb\\u8863\",\n",
       "                \"\\u9886\\u5e26\",\n",
       "                \"\\u88e4\\u5b50\",\n",
       "                \"\\u98ce\\u8863\",\n",
       "                \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                \"\\u889c\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 100,\n",
       "        \"inRange\": {\n",
       "            \"symbolSize\": [\n",
       "                20,\n",
       "                50\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"hoverLink\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"padding\": 5,\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "        chart_39309917bf49442dbdcc1e2c5c6eb619.setOption(option_39309917bf49442dbdcc1e2c5c6eb619);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111101210>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scatter = (\n",
    "    # 初始化设置Scatter图片宽600px，高300px\n",
    "    Scatter(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.clothes)\n",
    "    #使用Faker随机生成y轴数据\n",
    "    .add_yaxis(\"商家\", yValues)\n",
    "    # 在全局配置项中设置视觉映射\n",
    "    .set_global_opts(\n",
    "        # 设置根据y轴上第二个维度的值显示点的大小\n",
    "        visualmap_opts=opts.VisualMapOpts(type_=\"size\")\n",
    "    )\n",
    ")\n",
    "scatter.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "89d52b19-1e5a-4fd4-bfb4-0488c57c69f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"5dbe4b504c844be0a5d209c9f765678d\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_5dbe4b504c844be0a5d209c9f765678d = echarts.init(\n",
       "            document.getElementById('5dbe4b504c844be0a5d209c9f765678d'), 'white', {renderer: 'canvas'});\n",
       "        var option_5dbe4b504c844be0a5d209c9f765678d = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"\\u5546\\u5bb6\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u886c\\u886b\",\n",
       "                    71,\n",
       "                    32\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u6bdb\\u8863\",\n",
       "                    89,\n",
       "                    109\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9886\\u5e26\",\n",
       "                    62,\n",
       "                    110\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u88e4\\u5b50\",\n",
       "                    150,\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u98ce\\u8863\",\n",
       "                    73,\n",
       "                    124\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                    47,\n",
       "                    135\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u889c\\u5b50\",\n",
       "                    147,\n",
       "                    106\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u886c\\u886b\",\n",
       "                \"\\u6bdb\\u8863\",\n",
       "                \"\\u9886\\u5e26\",\n",
       "                \"\\u88e4\\u5b50\",\n",
       "                \"\\u98ce\\u8863\",\n",
       "                \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                \"\\u889c\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 100,\n",
       "        \"text\": [\n",
       "            \"\\u9ad8\",\n",
       "            \"\\u4f4e\"\n",
       "        ],\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"hoverLink\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"padding\": 5,\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "        chart_5dbe4b504c844be0a5d209c9f765678d.setOption(option_5dbe4b504c844be0a5d209c9f765678d);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111120f50>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scatter = (\n",
    "    # 初始化设置Scatter图片宽600px，高300px\n",
    "    Scatter(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.clothes)\n",
    "    #使用Faker随机生成y轴数据\n",
    "    .add_yaxis(\"商家\", yValues)\n",
    "    # 在全局配置项中设置视觉映射\n",
    "    .set_global_opts(\n",
    "        # 设置根据y轴上第二个维度的值显示点的颜色\n",
    "        # rang_text用于设置range条两端的文本\n",
    "        visualmap_opts=opts.VisualMapOpts(type_=\"color\", range_text=[\"高\", \"低\"])\n",
    "    )\n",
    ")\n",
    "scatter.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "103dbce5-6fe4-47ab-b924-1d100b0f848f",
   "metadata": {},
   "source": [
    "### TooltipOpts - 提示框配置项\n",
    "\n",
    "配置图像的提示框效果**在set_global_opts中配置**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2b0335b8-fd99-436c-9da6-9e4122205986",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"c85e67b3cef34b5d835f7d8a80b2e091\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_c85e67b3cef34b5d835f7d8a80b2e091 = echarts.init(\n",
       "            document.getElementById('c85e67b3cef34b5d835f7d8a80b2e091'), 'white', {renderer: 'canvas'});\n",
       "        var option_c85e67b3cef34b5d835f7d8a80b2e091 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"\\u5546\\u5bb6\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u886c\\u886b\",\n",
       "                    31\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u6bdb\\u8863\",\n",
       "                    59\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9886\\u5e26\",\n",
       "                    75\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u88e4\\u5b50\",\n",
       "                    83\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u98ce\\u8863\",\n",
       "                    97\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                    149\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u889c\\u5b50\",\n",
       "                    95\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"formatter\": \"\\u7cfb\\u5217\\u540d\\uff1a{a} | \\u6570\\u636e\\u540d\\uff1a{b} | \\u6570\\u636e\\u503c\\uff1a{c}\",\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u886c\\u886b\",\n",
       "                \"\\u6bdb\\u8863\",\n",
       "                \"\\u9886\\u5e26\",\n",
       "                \"\\u88e4\\u5b50\",\n",
       "                \"\\u98ce\\u8863\",\n",
       "                \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                \"\\u889c\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u63d0\\u793a\\u6846\\u914d\\u7f6e\\u9879\\u5b9e\\u9a8c\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false,\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_c85e67b3cef34b5d835f7d8a80b2e091.setOption(option_c85e67b3cef34b5d835f7d8a80b2e091);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1114ea3d0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scatter = (\n",
    "    # 初始化设置Scatter图片宽600px，高300px\n",
    "    Scatter(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.clothes)\n",
    "    #使用Faker随机生成y轴数据\n",
    "    .add_yaxis(\"商家\", Faker.values())\n",
    "    # 在全局配置项中设置视觉映射\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"提示框配置项实验\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(font_size=12)\n",
    "        ),\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            # {a}：系列名\n",
    "            # {b}：数据名（即x轴对应值）\n",
    "            # {c}：数据值（即x轴值加上y轴值）\n",
    "            formatter = '系列名：{a} | 数据名：{b} | 数据值：{c}'\n",
    "        )\n",
    "    )\n",
    ")\n",
    "scatter.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "aaa018c2-27a4-4216-b83d-3d9b9ab86b37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"bc0801d02eb44553a30ea7eea96f0129\" class=\"chart-container\" style=\"width:600px; height:300px; \"></div>\n",
       "    <script>\n",
       "        var chart_bc0801d02eb44553a30ea7eea96f0129 = echarts.init(\n",
       "            document.getElementById('bc0801d02eb44553a30ea7eea96f0129'), 'white', {renderer: 'canvas'});\n",
       "        var option_bc0801d02eb44553a30ea7eea96f0129 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"\\u5546\\u5bb6\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"\\u886c\\u886b\",\n",
       "                    32\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u6bdb\\u8863\",\n",
       "                    131\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9886\\u5e26\",\n",
       "                    111\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u88e4\\u5b50\",\n",
       "                    46\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u98ce\\u8863\",\n",
       "                    34\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                    138\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u889c\\u5b50\",\n",
       "                    75\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"formatter\":                 function(params){                    return params.name + params.value[1]                }                ,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u886c\\u886b\",\n",
       "                \"\\u6bdb\\u8863\",\n",
       "                \"\\u9886\\u5e26\",\n",
       "                \"\\u88e4\\u5b50\",\n",
       "                \"\\u98ce\\u8863\",\n",
       "                \"\\u9ad8\\u8ddf\\u978b\",\n",
       "                \"\\u889c\\u5b50\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"\\u63d0\\u793a\\u6846\\u914d\\u7f6e\\u9879\\u5b9e\\u9a8c\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false,\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_bc0801d02eb44553a30ea7eea96f0129.setOption(option_bc0801d02eb44553a30ea7eea96f0129);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1114e9310>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scatter = (\n",
    "    # 初始化设置Scatter图片宽600px，高300px\n",
    "    Scatter(init_opts=opts.InitOpts(\n",
    "        width=\"600px\",\n",
    "        height=\"300px\"\n",
    "    ))\n",
    "    # 使用Faker随机生成x轴数据\n",
    "    .add_xaxis(Faker.clothes)\n",
    "    #使用Faker随机生成y轴数据\n",
    "    .add_yaxis(\"商家\", Faker.values())\n",
    "    # 在全局配置项中设置视觉映射\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"提示框配置项实验\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(font_size=12)\n",
    "        ),\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            # JsCode可以嵌入自定义JS函数\n",
    "            formatter=JsCode(\n",
    "                \"\"\"\n",
    "                function(params){\n",
    "                    return params.name + params.value[1]\n",
    "                }\n",
    "                \"\"\"\n",
    "            )\n",
    "        )\n",
    "    )\n",
    ")\n",
    "scatter.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e795931-e5a5-4708-9617-192e9a6bf6c0",
   "metadata": {},
   "source": [
    "### AxisOpts - 轴配置项\n",
    "\n",
    "配置图像的轴显示效果**在set_global_opts中配置**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f7d76632-a3db-4dd1-92b5-9d15f1a7f1a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"b4af73650fdd4f4089ad758837da5d1e\" class=\"chart-container\" style=\"width:800px; height:400px; \"></div>\n",
       "    <script>\n",
       "        var chart_b4af73650fdd4f4089ad758837da5d1e = echarts.init(\n",
       "            document.getElementById('b4af73650fdd4f4089ad758837da5d1e'), 'white', {renderer: 'canvas'});\n",
       "        var option_b4af73650fdd4f4089ad758837da5d1e = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb61\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                12,\n",
       "                20,\n",
       "                30,\n",
       "                40,\n",
       "                50\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5546\\u5bb62\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                20,\n",
       "                30,\n",
       "                10,\n",
       "                50,\n",
       "                40\n",
       "            ],\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u5bb61\",\n",
       "                \"\\u5546\\u5bb62\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLine\": {\n",
       "                \"show\": true,\n",
       "                \"onZero\": true,\n",
       "                \"onZeroAxisIndex\": 0,\n",
       "                \"symbol\": \"arrow\",\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 2,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"show\": true,\n",
       "                \"alignWithLabel\": false,\n",
       "                \"inside\": true,\n",
       "                \"length\": 20\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"show\": true,\n",
       "                \"rotate\": -15,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"axisPointer\": {\n",
       "                \"show\": true,\n",
       "                \"type\": \"line\",\n",
       "                \"triggerTooltip\": true,\n",
       "                \"triggerOn\": \"mousemove|click\"\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u540d\\u5b57\\u5f88\\u957f\\u7684X\\u8f74\\u6807\\u7b7e\\u540d1\",\n",
       "                \"\\u540d\\u5b57\\u5f88\\u957f\\u7684X\\u8f74\\u6807\\u7b7e\\u540d2\",\n",
       "                \"\\u540d\\u5b57\\u5f88\\u957f\\u7684X\\u8f74\\u6807\\u7b7e\\u540d3\",\n",
       "                \"\\u540d\\u5b57\\u5f88\\u957f\\u7684X\\u8f74\\u6807\\u7b7e\\u540d4\",\n",
       "                \"\\u540d\\u5b57\\u5f88\\u957f\\u7684X\\u8f74\\u6807\\u7b7e\\u540d5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_b4af73650fdd4f4089ad758837da5d1e.setOption(option_b4af73650fdd4f4089ad758837da5d1e);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x111515790>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = (\n",
    "    # 初始化设置Bar图片宽600px，高300px\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width=\"800px\",\n",
    "        height=\"400px\"\n",
    "    ))\n",
    "    # 手动设置一个长名字x轴标签\n",
    "    .add_xaxis(\n",
    "        [\n",
    "            \"名字很长的X轴标签名1\",\n",
    "            \"名字很长的X轴标签名2\",\n",
    "            \"名字很长的X轴标签名3\",\n",
    "            \"名字很长的X轴标签名4\",\n",
    "            \"名字很长的X轴标签名5\",\n",
    "        ]\n",
    "    )\n",
    "    #使用Faker随机生成y轴数据\n",
    "        # gap=0，设置条行间的间隔为0\n",
    "    .add_yaxis(\"商家1\", [12, 20, 30, 40, 50])\n",
    "    #添加一组新的y轴取值，使用Faker随机生成y轴数据\n",
    "        # gap=0，设置条行间的间隔为0\n",
    "    .add_yaxis(\"商家2\", [20, 30, 10, 50, 40])\n",
    "    .set_global_opts(\n",
    "        # 以x轴为例示范AxisOpt的用法\n",
    "        xaxis_opts=opts.AxisOpts(\n",
    "            # 设置x轴label配置：转-15度\n",
    "            axislabel_opts=opts.LabelOpts(rotate=-15),\n",
    "            # 设置x轴线条配置\n",
    "            axisline_opts=opts.AxisLineOpts(symbol=\"arrow\", linestyle_opts=opts.LineStyleOpts(width=2)),\n",
    "            # 设置x轴刻度线\n",
    "            axistick_opts=opts.AxisTickOpts(is_inside=True, length=20),\n",
    "            # 设置x轴的鼠标辅助线效果\n",
    "            axispointer_opts=opts.AxisPointerOpts(is_show=True)\n",
    "        )\n",
    "    )\n",
    ")\n",
    "# 绘图\n",
    "bar.render_notebook()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
